<?php /* Smarty version 2.6.20, created on 2011-10-25 19:40:30
         compiled from _core/_include/module/_mvc/control/handlemails.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', '_core/_include/module/_mvc/control/handlemails.tpl', 35, false),)), $this); ?>
function HandleMails(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  
  this._query = (options && options.query) ? options.query : null;
  this._operator = (options && options.operator) ? options.operator : null;
  this._now = (options && options.now) ? options.now : null;
  this._menu = (options && options.menu) ? options.menu : null;
  this._smryGui = (options && options.smryGui) ? options.smryGui : null;
  this._smryArgs = (options && options.smryArgs) ? options.smryArgs : null;
  this._isSupervise = (options && options.s) ? options.s : 0;
  
  this._createElements();
};

HandleMails.prototype._createElements = function() {
  this._loadData();
};

HandleMails.prototype._verifyData = function() {
  if (this._produces) {
    this._updateElements();
  }
};

HandleMails.prototype._loadData = function() {
  this._produces = null;
  
  this._retrieveProduces();
};

HandleMails.prototype._retrieveProduces = function(page, condition) {
  var _self = this;
  condition = (condition) ? condition.replace('d.branch = \'<?php echo ((is_array($_tmp=@BRANCH)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
\' AND (' + this._query + ')' + ' AND ', '') : '';
  var joins = '&selects=0' + '&purchaseitems=0' + '&preconusers=0' + '&events=0' + '&tracks=0' + '&produces=0' + '&notes=1';
  var args = '&c=d.branch = \'<?php echo ((is_array($_tmp=@BRANCH)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
\' AND (' + this._query  + ')'+ ((condition) ? (' AND (' + condition + ')') : '') + '&p=' + ((page) ? page : 1) + '&s=20' + '&o=d.deadline' + '&q=ASC' + joins;
  new RequestUtils()._mysql('produce', args, function(result, params) { _self._produces = result.data;
                                                                        _self._parameters = result;
                                                                        _self._verifyData.call(_self);
                                                                      }, { php: Constant.FACTORY + '/customphp/produceread.php'});
};

HandleMails.prototype._retrieveProduces2 = function(page, condition) {
  var _self = this;
  condition = (condition) ? condition.replace('d.branch = \'<?php echo ((is_array($_tmp=@BRANCH)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
\' AND (' + this._query + ')' + ' AND ', '') : '';
  var args = '&c=d.branch = \'<?php echo ((is_array($_tmp=@BRANCH)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
\' AND (' + this._query + ')'+ ((condition) ? (' AND (' + condition + ')') : '') + '&p=' + ((page) ? page : 1) + '&s=20' + '&o=d.deadline' + '&q=ASC';
  new RequestUtils()._mysql('produce2', args, function(result, params) { _self._produces = result.data;
                                                                         _self._parameters = result;
                                                                         _self._verifyData.call(_self);
                                                                        }, { php: Constant.FACTORY + '/customphp/produceread.php'});
};

HandleMails.prototype._updateElements = function() {
  var _self = this;
  DOMUtils.removeChildElements(this._gui.pages);
  DOMUtils.removeChildElements(this._gui.tasks);
  
  if (this._smryGui && this._smryArgs) {
    new HandleSmry(this._smryGui, null, { args: this._smryArgs });
  }
  
  var gui = GuiSearchMail.instance(this._gui.mailNo, this._gui.customerNo, this._gui.product, this._gui.search);
  new HandleSearchMail(gui, this._item, { callbackFunc: function(condition) { _self._retrieveProduces2.call(_self, 1, condition); }, query: 'd.branch = \'<?php echo ((is_array($_tmp=@BRANCH)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
\' AND (' + this._query + ')' });
  
  Pagination.makePagedResults(this._gui.pages, this._parameters.page, this._parameters.total, this._parameters.size, function(page, condition) { _self._retrieveProduces.call(_self, page, _self._parameters.condition); }, this, document);
  
  new TableProduces(this._gui.tasks, this._produces, { user: this._operator, date: this._now, callbackFunc: function() { _self._retrieveProduces.call(_self, 1, _self._parameters.condition); }, hidePrice: true, menu: this._menu, mails: true, s: this._isSupervise });
};